import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import i18n from './locales';
import './styles/index.less';
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';

// 创建应用实例
const app = createApp(App);
// pinia数据持久化
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

// 使用插件
app
  .use(createPinia())
  .use(router)
  .use(ElementPlus, { locale: zhCn })
  .use(i18n)
  .use(pinia);

// 挂载应用
app.mount('#app');
